package com.scau.ums.util.dao;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class SelectTaskSql {
    public String SelectTask(Map<String, Object> map){
        //联表查询维修工正在进行的施工的维修单
        String sql=null;
        String maintainId=(String)map.get("id");
        String state=(String)map.get("state");
        sql="SELECT repairTaskOrder.reportId,maintainerId,state,reporterId,reporterName,reporterType,telephone,mail,dormRegion,dormBuilding,dormRoom,repairDesc,date \n" +
                "FROM repairTaskOrder,repairReport \n" +
                "WHERE repairTaskOrder.reportId=repairReport.id  and state="+state+" and maintainerId="+maintainId;
        return sql;
    }


    //

    public String SelectInfo(Map<String, Object> map){
        //联表查询维修工正在进行的施工的维修单
        String sql=null;
        String maintainId=(String)map.get("id");
        String state=(String)map.get("state");
        sql="SELECT repairTaskOrder.reportId,maintainerId,state,reporterId,reporterName,reporterType,telephone,mail,dormRegion,dormBuilding,dormRoom,repairDesc,date,repairEvaluation.remark\n" +
                "FROM repairTaskOrder,repairReport,repairEvaluation \n" +
                "WHERE repairTaskOrder.reportId=repairReport.id and repairReport.id=repairEvaluation.repairReportId and state="+state+" and maintainerId="+maintainId;
        return sql;
    }




    public String UpadateTaskState(Map<String, Object> map){
        //联表查询维修工正在进行的施工的维修单
        String sql=null;
        String reportId=(String)map.get("id");
        String state=(String)map.get("state");
        sql="UPDATE `ums`.`repairReport` \n" +
                " SET state = "+state+
                " WHERE id = "+reportId;
        return sql;
    }

    public String allowCancelTaskList(){
        //联表查询允许取消的维修单
        return "select * from repairTaskOrder where reportId in \n" +
                "(select id as reportId from repairReport where state = 3);";
    }
}
